package com.demo.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.demo.model.AIDAXiuModel;
import com.demo.widget.model.ShowMode;
import com.demo.widget.model.ViewInfo;
import com.example.androiddemo.R;

public class ImageAdapter extends NBaseAdapter {

	private LayoutInflater inflater;
	private List<AIDAXiuModel> mdata;
	private int mResource;

	public ImageAdapter(Context context, List<AIDAXiuModel> data, int resource) {
		inflater = LayoutInflater.from(context);
		this.mdata = data;
		this.mResource = resource;
	}

	@Override
	public int getCount() {
		return mdata.size();
	}

	@Override
	public Object getItem(int position) {
		return mdata.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			convertView = inflater.inflate(mResource, null);
		}

		AIDAXiuModel model = mdata.get(position);
		String imageURL = model.getConver();
		ViewInfo viewInfo = new ViewInfo();
		viewInfo.setImageURL(imageURL);
		viewInfo.setMode(ShowMode.IMAGE);
		convertView.setTag(viewInfo);

		return convertView;
	}

	public ImageView getImageView(View convertView) {
		ImageView realImageView = (ImageView) convertView.findViewById(R.id.realImage);
		return realImageView;
	}
}
